package com.glodon.paas.document.storage;

import java.io.IOException;
import java.io.InputStream;

import com.glodon.paas.document.storage.model.Node;

public class StorageFile {

    private Node node;
    private Storage storage;

    public StorageFile(Storage storage, Node node) {
        this.storage = storage;
        this.node = node;
    }

    public InputStream getInputStream() throws IOException {
        return getInputStream(0);
    }

    public InputStream getInputStream(long start) throws IOException {
        return node.getObjectId() == null ? null : storage.getInputStreamById(node.getObjectId(), start);
    }

    public long getVersion() {
        return node.getVersion();
    }

    public boolean isDeleted() {
        return node.isDeleted();
    }

    public boolean isFolder() {
        return node.isFolder();
    }

    public long length() {
        return node.getLength();
    }
}
